package techstudy;

import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

class TestOrderDemo {
	
	@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
	public static class OrderAnnotation {
		// 按照Order次序由小到大
		@Test
		@Order(3)
		void test1() {
			System.out.println(1);
		}

		@Test
		@Order(1)
		void test3() {
			System.out.println(3);
		}

		@Test
		@Order(2)
		void test2() {
			System.out.println(2);
		}
		
		@Test
		void testMethod1() {
			System.out.println(1);
		}

		@Test
		void testMethod3() {
			System.out.println(3);
		}

		@Test
		void testMethod2() {
			System.out.println(2);
		}

	}

	static class MethodNameOrder {
		// 没有Order时按照方法名字次序
		@Test
		void testMethod1() {
			System.out.println(1);
		}

		@Test
		void testMethod3() {
			System.out.println(3);
		}

		@Test
		void testMethod2() {
			System.out.println(2);
		}
	}

}
